d_global_debug = 0;

waitUntil{!isNil "BIS_fnc_init"};
call mso_core_fnc_isHC;

X_INIT = false;X_Server = false; X_Client = false; X_JIP = false;X_SPE = false;X_MP = isMultiplayer;
X_LOADED = false;
X_PLAYER_INIT = false;

call compile preprocessFileLineNumbers "base\functions.sqf";
call compile preprocessFileLineNumbers "base\common\editorfunctions.sqf";
call compile preprocessFileLineNumbers "base\common\commonfunctions.sqf";
call compile preprocessFileLineNumbers "base\common\hash_array.sqf";
call compile preprocessFileLineNumbers "base\common\netfunctions.sqf";
call compile PreProcessFileLineNumbers "base\common\building_position.sqf";
call compile preprocessFileLineNumbers "base\client\player_functions.sqf";
call compile preprocessFileLineNumbers "base\client\clientfunctions.sqf";
call compile PreProcessFileLineNumbers "base\mission\mission_functions.sqf";
call compile PreProcessFileLineNumbers "base\server\R3F_FNCT_ied.sqf";
call compile PreProcessFileLineNumbers "base\server\serverfunctions.sqf";
call compile PreProcessFileLineNumbers "base\server\artillery.sqf";

diag_log "all functions compiled";

#define __waitpl [] spawn {waitUntil {!isNull player};X_INIT = true}
if (isServer) then {
	X_Server = true;
	if (!isDedicated) then {
		X_Client = true;
		X_SPE = true;
		__waitpl;
	} else {
		X_INIT = true;
	};
} else {
	X_Client = true;
	if (isNull player) then {
		X_JIP = true;
		__waitpl;
	} else {
		X_INIT = true;
	};
};

enableSaving [false, false];

#ifndef execNow
#define execNow call compile preprocessfilelinenumbers
#endif

#include "i_common.sqf";

CBA_ui_fnc_add = {};
cba_fnc_replace = {};

titleCut ["", "BLACK FADED", 999];
titleText ["Initialising...", "BLACK"];
waitUntil{!isNil "BIS_fnc_init"};
call mso_core_fnc_isHC;

execNow "base\core\init.sqf";
execNow "base\mission\init.sqf";
execNow "base\support\init.sqf";

if (X_SERVER) then {
	#include "i_server.sqf";
};

if (X_CLIENT) then {
	#include "i_client.sqf";
};


"Completed" call mso_core_fnc_initStat;
diag_log format["MSO-%1 Initialisation Completed", time];
titleCut ["", "BLACK IN", 3];
titleText ["Initialisation Completed", "BLACK IN"];

X_LOADED = true;

if (X_CLIENT) then {
	execNow "base\core\scripts\intro.sqf";
};